home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
asmutil
/
asm_n_z.zip
/
TT.ASM
< prev
next >
Wrap
Assembly Source File
|
1988-02-22
|
21KB
|
848 lines
COMMENT * ==================================================================
Copyright (C) 1988, George A. Stanislav.
All Rights Reserved.
This program is a dumb terminal for FOSSIL communications.
It works only from the COM1 port and only at 300/1200/2400
baud, with a built-in ansi-bbs and AVATAR terminal emulation.
That means that if you call a BBS supporting ANSI graphics,
it should correctly recognize the movement of your cursor keys,
as well as the <home> and <end> keys. More importantly, if
the BBS sends out Opus color codes, the AVATAR emulator will
convert them to ANSI sequences. You need ANSI.SYS properly
installed for either emulation to work properly.
The purpose of this program is mostly didactical. Lesson 2
of FOSSIL programming. (Lesson 1 was the previous version,
called DUMBTERM.) You can probably add Lesson 3 as of version
1.02, the lesson is contained in the AVATAR emulator.
New in version 1.03 are 20 user configurable keys. With the
help of TTSETUP.COM, you can configure the 10 function keys
when combined with either <ctl> or <alt> for a string up to
32 characters long. The same program will allow you to choose
defaults other than those coded here.
While the program is a dumb terminal, it allows you to transfer
file using the Zmodem protocol. For that, however, you need
TWO additional programs: Author's PROZ.COM and Chuck Forsberg's
DSZ.COM or DSZ.EXE. Of the two, PROZ.COM must be in the current
default directory, while DSZ can be anywhere as long as the
PATH environmental variable is pointing at it.
You can freely copy it and give it to others. The word FREELY
is substantial. Any charge imposed in connection with passing
this program onto someone else is in direct violation with
my Copyright. That also means that anyone who sells diskettes
or other media with public domain or shareware programs is
expressly prohibited from distributing this program. This program
is NOT in public domain!
Usage:
As it is a very simple terminal indeed, all you need is
a 300, 1200, or 2400 baud modem attached to COM1 and
type TT.
Whatever you type thereafter goes directly into the
modem. To dial a number you will have to type
ATDT 123-4567 <cr>. To initialize the modem, you
will have to type ATZ or whatever your modem manual
suggests.
To exit the program, type ^END. That means you can use
^C online.
Obviously, you cannot use this program for file transfers. This
is just a dumb terminal.
Support form author:
None.
* ===========================================================================
; MACROS to make it look like a high level language
fossil macro ; call FOSSIL driver
int 14h
endm
dos macro ; call MS DOS
int 21h
endm
print macro text
mov ah,09h ; display string
ifnb <text>
mov dx,offset text ; point to it
endif
dos
endm
exit macro level
mov ax,4c00h + level ; ah = 4ch, al = level
dos
endm
port macro ; choose COM1
mov dx,cport ; dx = cport
fossil ; call the driver
endm
setB macro rate ; set baud rate
ifnb <rate>
mov al,baud ; that's ah = 0, al = 10000011 initially
endif
xor ah,ah
port ; COM1
endm
csend macro ; transmit a character from al
mov ah,1 ; the character must already be in al
port
endm
crec macro ; receive a character from fossil buffer
mov ah,2 ; the received character will be in al
port
endm
open macro
local opened,oldfos,done
mov ah,4 ; initialize fossil
port
cmp ax,1954h ; the fossil "magic" number
je opened ; achieved
print msg ; fossil not present
exit 1 ; abort with errorlevel 1
opened: cmp bh,4 ; need at least FOSSIL, rev. 4
jb oldfos
cmp bl,19h ; can we write a block?
jnb done ; yes, done
oldfos: add oldrev,bh ; fix error message
print neednew ; print error message
exit 2 ; abort with errorlevel 2
done:
endm
close macro ; cleanup
mov ah,5
port
endm
dtr macro onoroff
mov ax,600h + onoroff ; on = 1, off = 0
port
endm
finkey macro ; fossil "inkey"
mov ah,0ch
port
inc ax ; zero flag = 0 if nothing there
endm
inkey macro ; keyboard "inkey"
mov ah,0dh
fossil ; never mind the port
inc ax ; check zero flag
endm
cget macro ; read character from keyboard
mov ah,0eh
fossil
endm
cput macro ; display a character
mov ah,13h ; character must be in al
fossil
endm
sends macro string,strlen
ifnb <string>
mov di,offset string
mov cx,strlen
endif
mov ah,19h
fossil
endm
talk macro
local talk1,talked ; talk to the other end
inkey ; check if the keyboard has been hit
jz talked ; no it was not, keep quiet
cget ; yes, see what it is
or al,al ; is it a function key?
jne talk1 ; no, send it out
call funkey ; process function key
jmp short talked
talk1: csend ; send char out
talked:
endm
listen macro
local l1,listen1,listened ; listen to the other end
finkey ; anything there?
jz listened ; nope
crec ; receive character
cmp al,26 ; is it a control character?
ja listen1 ; no, check further
l1: call avatar ; advanced video attribute transfer
jmp short listened
listen1:cmp avaflag,0 ; are we processing avatar?
jne l1 ; yes, call avatar
cput ; no, display it
listened:
endm
chat macro
local keep
keep:
talk
listen
jmp keep
endm
sendc macro char
mov al,char
csend
endm
; DEFINES
ctlA equ 1
ctlB equ 2
ctlC equ 3
ctlD equ 4
ctlE equ 5
ctlF equ 6
ctlG equ 7
ctlH equ 8
ctlL equ 12
ctlV equ 22
ctlY equ 25
cr equ 13
dle equ 16
lf equ 10
bell equ 7
stop equ '$'
on equ 1
off equ 0
tab equ 9
bmask equ 00011111b ; baud rate mask
b3 equ 01000000b ; 300 baud mask
b12 equ 10000000b ; 1200 baud mask
b24 equ 10100000b ; 2400 baud mask
pmask equ 11100000b ; parity etc. mask
p7E1 equ 00011010b ; mask for 7E1
p8N1 equ 00000011b ; mask for 8N1
imask equ 00001000b ; intensity bit
fgrmask equ 00000111b ; foreground color mask
bkgmask equ 01110000b ; background color
black equ 0
blue equ 1
green equ 2
cyan equ 3
red equ 4
magenta equ 5
brown equ 6
white equ 7
vflag equ 1 ; ^v received
aflag equ 2 ; ^v^a received
yflag equ 3 ; ^y received
yflag2 equ 4 ; ^y received, repeat character known
hflag equ 5 ; ^v^h received
hflag2 equ 6 ; ^v^h received, row known
noflag equ 0
; The PROGRAM
dumb segment
assume ds:dumb,es:dumb,cs:dumb,es:dumb
org 100h
main proc
start: jmp begin
version dw 0104h ; 1.04
cport dw 0 ; start with COM1
baud db 10000011b ; start with 1200 baud 8N1
editor db 0,' /C ',80 dup(0) ; space for editor
macword label word
mac db 20 dup (32 dup (?)) ; space for 20 key macros
macount db 20 dup (0) ; sizes of 20 key macros
copr db cr,lf,'TinyTerm - ANSI & AVATAR Emulating Terminal, version 1.04',cr,lf
db 'Copyright (C) 1988, George A. Stanislav',cr,lf
db 'All Rights Reserved.',cr,lf,lf
db 'This is a very simple terminal. Whatever you type '
db '(except ^<end>) is sent',cr,lf
db 'straight to the modem. Its initial setup is 1200 baud, 8N1, from '
db 'COM1. The full',cr,lf
db 'assembly language source code is included so you can write '
db 'your own programs',cr,lf
db 'using other configurations. The goal of this program is to '
db 'show to as many',cr,lf
db 'as possible how to write FOSSIL communications programs '
db 'and AVATAR emulation.',cr,lf,lf
db 'TinyTerm allows you to configure the 10 function keys '
db 'combined with the',cr,lf
db '<alt> or <ctl> keys as "macros". You can either define '
db 'them in the source',cr,lf
db 'code or, better yet, by running TTSETUP.COM. This also '
db 'allows you to choose',cr,lf
db 'defaults other than COM1, 1200 baud and 8N1.',cr,lf,lf
db 'Hit <F10> for help, <Ctrl> <End> to exit.',cr,lf,lf,stop
msg db 'FOSSIL not found. In order to run this program you need to '
db 'load a FOSSIL',cr,lf
db 'communications driver before you call TINYTERM.',cr,lf,stop
neednew db cr,lf,lf,'You are using revision '
oldrev db '0 of FOSSIL. For T